﻿app.directive('churchworker', function ($rootScope) {
    return {
        link: function (scope, el, attr) {
            scope.$watch(attr.axisvalues, function (xaxisvalue) {
               
                scope.xaxis = [];
                scope.yaxis = [];
                for (var i = 0; i <= xaxisvalue.length - 1; i++) {
                    scope.xaxis.push(xaxisvalue[i].ChurchWorkerDesignationName);
                    scope.yaxis.push(xaxisvalue[i].Counts);
                }
                Highcharts.chart(attr.id, {
                    chart: {
                        type: 'column',
                        options3d: {
                            enabled: true,
                            alpha: 10,
                            beta: 25,
                            depth: 70
                        }
                    },
                    title: {
                        text: 'Church Worker counts with Designations'
                    },
                    subtitle: {
                        text: ''
                    },
                    plotOptions: {
                        column: {
                            depth: 25
                        }
                    },
                    xAxis: {
                        categories: scope.xaxis
                    },
                    yAxis: {
                        title: {
                            text: null
                        }
                    },
                    series: [{
                        name: 'Designation',
                        data: scope.yaxis
                    }]
                });
            });
          
            
        }
    };
})